//
//  tree_DatasourceManager.h
//  Accordion
//
//  Created by Enriquez Gutierrez Guillermo Ignacio on 8/27/10.
//  Copyright (c) 2010 Nacho4D.
//  See the file license.txt for copying permission.
//

#import <UIKit/UIKit.h>
#import "Data_Model.h"

@class treeNode;

@class tree_DatasourceManager;

@protocol tree_DatasourceManagerDelegate <NSObject>

@required
- (void) fileAccordionDatasourceManager:(tree_DatasourceManager *) manager didInsertRowsAtIndexPaths:(NSArray *)indexPaths;
- (void) fileAccordionDatasourceManager:(tree_DatasourceManager *) manager didSelecrRowsAtIndexPaths:(NSArray *)indexPaths;
- (void) fileAccordionDatasourceManager_tree_reload;
- (void) fileAccordionDatasourceManager:(tree_DatasourceManager *) manager didRemoveRowsAtIndexPaths:(NSArray *)indexPaths;
- (void) fileAccordionDatasourceManager:(tree_DatasourceManager *) manager didCreateSuccessfullyFile:(treeNode *)file;
- (void) fileAccordionDatasourceManager:(tree_DatasourceManager *) manager didFailOnCreationofFile:(treeNode *) file error:(NSError *)error;

 

@end


@interface tree_DatasourceManager : NSObject {
	
	NSMutableArray *_sortDescriptors;
	
    NSMutableArray *_mergedRootBranch;
	NSMutableDictionary *_unmergedBranches;
	
    id<tree_DatasourceManagerDelegate> delegate;
	
    treeNode *rootDirectory;
       
    Data_Model *datamodel_N4;
    
}

@property (nonatomic, retain) NSMutableArray *sortDescriptors;
@property (nonatomic, retain, readonly) NSMutableArray * mergedRootBranch;
@property (nonatomic, assign) id<tree_DatasourceManagerDelegate> delegate;

+ (NSMutableArray *) defaultSortDescriptors;


//初始化
- (id) initWithRootPath:(NSString *)path sortDescriptors:(NSMutableArray *)sortDescs datamodel:(Data_Model *)dm;
 
//展開與收斂 功能
- (void) expandBranchAtIndex:(NSInteger)index;
- (void) collapseBranchAtIndex:(NSInteger)index;


//群組與觀察名單 功能
//拷貝
- (void) copy_AtIndex:(NSInteger)index;



//增加
- (void) createDirectoryAtIndex_level_same:(NSInteger)index withName:(NSString *)fileName;
- (void) createDirectoryAtIndex_level_sub:(NSInteger)index withName:(NSString *)fileName;
- (void) createWatchlistAtIndex_level_same:(NSInteger)index withName:(NSString *)fileName;
- (void) createWatchlistAtIndex_level_sub:(NSInteger)index withName:(NSString *)fileName;
//更名
- (void) rename_AtIndex:(NSInteger)index newname:(NSString *)newname;
//刪除
- (void) deleteFileAtIndex:(NSInteger)index;
//移動
- (void)treeNodemoveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath;


@end
